package org.zhadoop.stream.cql.semanticanalyzer.parser.visitor;

import java.util.Locale;

import org.zhadoop.stream.cql.semanticanalyzer.parser.CQLParser.ColumnNameTypeListContext;
import org.zhadoop.stream.cql.semanticanalyzer.parser.CQLParser.ParallelClauseContext;
import org.zhadoop.stream.cql.semanticanalyzer.parser.CQLParser.SerdeClassContext;
import org.zhadoop.stream.cql.semanticanalyzer.parser.CQLParser.SerdePropertiesContext;
import org.zhadoop.stream.cql.semanticanalyzer.parser.CQLParser.SinkClauseContext;
import org.zhadoop.stream.cql.semanticanalyzer.parser.CQLParser.SinkPropertiesContext;
import org.zhadoop.stream.cql.semanticanalyzer.parser.CQLParser.StreamNameContext;
import org.zhadoop.stream.cql.semanticanalyzer.parser.context.CreateOutputStatementContext;

public class CreateOutputStreamVisitor extends AbsCQLParserBaseVisitor<CreateOutputStatementContext>{

	private CreateOutputStatementContext context = null;
	
	public CreateOutputStreamVisitor() {
		context = new CreateOutputStatementContext();
	}
	
	@Override
	protected CreateOutputStatementContext defaultResult() {
		return context;
	}
	
	@Override
	public CreateOutputStatementContext visitStreamName(StreamNameContext ctx) {
		context.setStreamName(ctx.getText().toLowerCase(Locale.US));
		return context;
	}
	
	@Override
	public CreateOutputStatementContext visitColumnNameTypeList(ColumnNameTypeListContext ctx) {
		ColumnNameTypeListVisitor visitor = new ColumnNameTypeListVisitor();
		context.setColumns(visitor.visit(ctx));
		return context;
	}
	
	@Override
	public CreateOutputStatementContext visitSerdeClass(SerdeClassContext ctx) {
		ClassNameVisitor visitor = new ClassNameVisitor();
		context.setSerClassName(visitor.visit(ctx));
		return context;
	}
	
	@Override
	public CreateOutputStatementContext visitSerdeProperties(SerdePropertiesContext ctx) {
		StreamPropertiesVisitor visitor = new StreamPropertiesVisitor();
		context.setSerProperties(visitor.visit(ctx));
		return context;
	}
	
	@Override
	public CreateOutputStatementContext visitSinkClause(SinkClauseContext ctx) {
		ClassNameVisitor visitor = new ClassNameVisitor();
		context.setSinkClassName(visitor.visit(ctx));
		return context;
	}
	
	@Override
	public CreateOutputStatementContext visitSinkProperties(SinkPropertiesContext ctx) {
		StreamPropertiesVisitor visitor = new StreamPropertiesVisitor();
		context.setSinkProperties(visitor.visit(ctx));
		return context;
	}
	
	@Override
	public CreateOutputStatementContext visitParallelClause(ParallelClauseContext ctx) {
		ParallelClauseVisitor visitor = new ParallelClauseVisitor();
		context.setParallelNumber(visitor.visit(ctx));
		return context;
	}
	
}
